package com.budwk.app.utils;

import org.nutz.ioc.Ioc;
import org.nutz.ioc.impl.PropertiesProxy;
import org.nutz.mvc.NutConfig;
import org.nutz.mvc.Setup;

/**
 * @author ZY.Wang
 * @since 2023/8/9
 */
public class NutzIocUtils implements Setup {

    public static Ioc ioc;

    public void init(NutConfig conf) {
        NutzIocUtils.ioc = conf.getIoc();
    }

    @Override
    public void destroy(NutConfig nutConfig) {

    }

    public static Ioc getIoc() {
        return ioc;
    }

    public static PropertiesProxy getPropertiesProxy() {
        return ioc.getByType(PropertiesProxy.class);
    }

    public static String getUploadPath() {
        return getPropertiesProxy().get("storage.local.path");
    }

    public static <T> T getBean(Class<T> clazz) {
        return ioc.getByType(clazz);
    }

}
